﻿package {
	import flash.display.*;
	import flash.text.*;
	
	public class ScoreBox extends Sprite {

		var rectangle = new Sprite();
		var humansSavedText:TextField = new TextField();
		var humansScoreText:TextField = new TextField();
		var humansTurnedText:TextField = new TextField();
		var zombiesScoreText:TextField = new TextField();
		var zombiesRemainingText:TextField = new TextField();

		var humansSaved = 0;
		var humansScore = 0;
		var humansTurned = 0;
		var zombiesScore = 0;
		var zombiesRemaining = 0;

		public var scale:Number = 0.5;
				
		public function ScoreBox() {
			init();	
		}
		
		public function init() {
			initSprite();
		}
		
		public function initSprite()
		{
			rectangle.graphics.lineStyle(1, 0x000000);
			rectangle.graphics.beginFill(0x000000);
			rectangle.graphics.drawRect(0, 0, 650, 20);
			rectangle.graphics.endFill();
			addChild(rectangle);
			
			zombiesScoreText.textColor = 0x00FF00;
			zombiesScoreText.autoSize = TextFieldAutoSize.LEFT;
			zombiesScoreText.x = 520;
			zombiesScoreText.y = 0;
			addChild(zombiesScoreText);
			
			humansScoreText.textColor = 0x00FF00;
			humansScoreText.autoSize = TextFieldAutoSize.LEFT;
			humansScoreText.x = 390;
			humansScoreText.y = 0;
			addChild(humansScoreText);
			
			humansSavedText.textColor = 0x00FF00;
			humansSavedText.autoSize = TextFieldAutoSize.LEFT;
			humansSavedText.x = 260;
			humansSavedText.y = 0;
			addChild(humansSavedText);

			humansTurnedText.textColor = 0x00FF00;
			humansTurnedText.autoSize = TextFieldAutoSize.LEFT;
			humansTurnedText.x = 120;
			humansTurnedText.y = 0;
			addChild(humansTurnedText);

			zombiesRemainingText.textColor = 0x00FF00;
			zombiesRemainingText.autoSize = TextFieldAutoSize.LEFT;
			zombiesRemainingText.x = 5;
			zombiesRemainingText.y = 0;
			addChild(zombiesRemainingText);
			
			updateText();
		}
		
		public function setHumansSaved(amount)
		{
			this.humansSaved = amount;
			updateText();
		}		
		
		public function incrementHumansSaved(amount)
		{
			this.humansSaved += amount;
			updateText();
		}
		
		public function incrementHumansScore(amount)
		{
			this.humansScore += amount;
			updateText();
		}
		
		public function incrementZombiesScore(amount)
		{
			this.zombiesScore += amount;
			updateText();
		}
		
		public function decrementHumansSaved(amount)
		{
			this.humansSaved -= amount;
			updateText();
		}

		public function setHumansTurned(amount)
		{
			this.humansTurned = amount;
			updateText();
		}

		public function setHumansScore(amount)
		{
			this.humansScore = amount;
			updateText();
		}

		public function setZombiesScore(amount)
		{
			this.zombiesScore = amount;
			updateText();
		}

		public function incrementHumansTurned(amount)
		{
			this.humansTurned += amount;
			updateText();
		}

		public function decrementHumansTurned(amount)
		{
			this.humansTurned -= amount;
			updateText();
		}
		
		public function setZombiesRemaining(amount)
		{
			this.zombiesRemaining = amount;
			updateText();
		}

		public function incrementZombiesRemaining(amount)
		{
			this.zombiesRemaining += amount;
			updateText();
		}

		public function decrementZombiesRemaining(amount)
		{
			this.zombiesRemaining -= amount;
			updateText();
		}
		
		public function updateText()
		{
			humansSavedText.text = "HUMANS SAVED: " + humansSaved;
			humansTurnedText.text = "HUMANS TURNED: " + humansTurned;
			zombiesRemainingText.text = "ZOMBIES LEFT: "+ zombiesRemaining;
			humansScoreText.text = "HUMANS SCORE: "+ humansScore;
			zombiesScoreText.text = "ZOMBIES SCORE: "+ zombiesScore;
		}
	}
}